% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ejscreenRESTbroker.R
\name{ejscreenRESTbroker}
\alias{ejscreenRESTbroker}
\title{Low-level utility to query EJScreen API for one circular buffer}
\usage{
ejscreenRESTbroker(
  lon = NULL,
  lat = NULL,
  radius = 3,
  fips = NULL,
  namestr = "",
  shapefile = NULL,
  url = c("https://ejscreen.epa.gov/mapper/ejscreenRESTbroker1.aspx?",
    "https://ejscreen.epa.gov/mapper/ejscreenRESTbroker.aspx?")[1],
  ipurl = "ejscreen.epa.gov",
  wkid = 4326,
  unit = 9035,
  f = "pjson",
  reportstyle = c("EJscreen_SOE_report", "EJSCREEN_report")[1]
)
}
\arguments{
\item{lon}{a longitude}

\item{lat}{a latitude}

\item{radius}{radius of the circular buffer (normally in miles)}

\item{fips}{If specified, lon and lat are ignored, and the one fips code must be the
FIPS code of a blockgroup or tract, or county (5 digits with leading zero)
or city/town/cdp/etc. (7 digits with leading zero).
A character string is best, with leading zero if relevant.}

\item{namestr}{optional text}

\item{shapefile}{not implemented}

\item{url}{URL base for API (provides access to the shorter version vs default longer list of indicators),
where newer 2023 version is default, using ejscreenRESTbroker1.aspx,
and old style/mini version is at ejscreenRESTbroker.aspx}

\item{ipurl}{fixed ip or domain/URL to try}

\item{wkid}{spatial reference. https://epsg.io/4326}

\item{unit}{9035 for miles, 9036 for kilometers, but default is miles}

\item{f}{pjson for results in JSON format, or report for the URL of the pdf report}

\item{reportstyle}{EJscreen_SOE_report for the full community profile that was new as of 7/2023,
or EJSCREEN_report for the older style standard report (which has fewer indicators on it).}
}
\value{
Returns JSON by default. See source code of this function for notes on format.
status_code
}
\description{
Use EJScreen API to get raw json-format response, ready to be
parsed by \code{\link[=ejscreenRESTbroker2table]{ejscreenRESTbroker2table()}}. This function underlies higher level
functions like \code{\link[=ejscreenapi]{ejscreenapi()}} and overall \code{\link[=ejscreenit]{ejscreenit()}}
}
\details{
Note the public and internal IP addresses differ.

See \url{https://ejscreen.epa.gov/mapper/ejscreenRESTbroker1.aspx?geometry={\%22spatialReference\%22:{\%22wkid\%22:4326},\%22x\%22:-100.2,\%22y\%22:36}&distance=1&unit=9035&f=json}

for example of json output format, or see source code of this function.

See \url{https://ejscreen.epa.gov/mapper/EJscreen_SOE_report.aspx?namestr=&geometry={\%22spatialReference\%22:{\%22wkid\%22:4326},\%22x\%22:-100.12811027526683,\%22y\%22:36.6582500495267}&distance=10&unit=9035&areatype=&areaid=&f=report}
for an example of the pdf report output.

Note some variables are duplicated in outputs.

API: Introduction to how the API works:
\itemize{
\item \url{https://www.epa.gov/ejscreen/ejscreen-api}
}

API: Simple web interface to try out the API and learn how parameters can be specified in URL:
\itemize{
\item 2023_07         ver 2.2         \url{https://ejscreen.epa.gov/mapper/ejscreenapi1.html}
\item old style/mini ver 2.2 (fewer indicators) \url{https://ejscreen.epa.gov/mapper/ejscreenapi.html}
}

API: REST endpoint:
\itemize{
\item 2023_07  ver 2.2 \url{https://ejscreen.epa.gov/mapper/ejscreenRESTbroker1.aspx?namestr=}
\item old style/mini ver 2.2 \url{https://ejscreen.epa.gov/mapper/ejscreenRESTbroker.aspx?namestr=}
}

csv/gdb files: Data dictionary for downloadable dataset:
\itemize{
\item 2023_07  ver 2.2 \url{https://gaftp.epa.gov/EJScreen/2023/EJSCREEN_2023_BG_Columns.xlsx}
}

API: Data dictionary of variable names:
\itemize{
\item 2023_07  ver 2.2 \url{https://ejscreen.epa.gov/mapper/ejsoefielddesc1.html}
\item old style/mini ver 2.2 \url{https://ejscreen.epa.gov/mapper/ejsoefielddesc.html}
}

Webpage explaining the indicators
\itemize{
\item ver 2.2  \url{https://origin-awswest-www.epa.gov/ejscreen/ejscreen-map-descriptions}
}

Web tool user guide:
\itemize{
\item 2023_07         ver 2.2 \url{https://ejscreen.epa.gov/mapper/help/ejscreen_help.pdf}
}
}
\examples{
\dontrun{
  browseURL(ejscreenRESTbroker(lon = -80, lat = 42, f = 'report'))
  
  x = ejscreenRESTbroker(lon = -80, lat = 42) 
  df = ejscreenRESTbroker2table(x)
  class(df)
  t(df)
  
  x = ejscreenRESTbroker(lon = -80, lat = 42) 
  names(x)
  x$url
  x$status_code
  names(jsonlite::fromJSON(rawToChar(x$content)))
  names(jsonlite::fromJSON(rawToChar(x$content))$data)
  names(jsonlite::fromJSON(rawToChar(x$content))$data$main)
  names(jsonlite::fromJSON(rawToChar(x$content))$data$extras)
  names(jsonlite::fromJSON(rawToChar(x$content))$data$demographics)
  }

}
\seealso{
\code{\link[=ejscreenit]{ejscreenit()}}  or
\code{\link[=ejscreenit]{ejscreenit()}} which use \code{\link[=ejscreenapi_plus]{ejscreenapi_plus()}}
and that uses \code{\link[=ejscreenapi]{ejscreenapi()}} that uses \code{\link[=ejscreenapi1]{ejscreenapi1()}} and \code{\link[=ejscreenRESTbroker]{ejscreenRESTbroker()}} and \code{\link[=ejscreenRESTbroker2table]{ejscreenRESTbroker2table()}}
}
\keyword{internal}
